package com.knight.spring.aop.transaction;

import com.knight.service.StudentService;
import com.knight.spring.bean.Student;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class SpringTransactionClient {
    public static void main(String[] args) {
        Resource resource = new ClassPathResource("applicationContext-transaction.xml");

        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);

        xmlBeanDefinitionReader.loadBeanDefinitions(resource);

        StudentService studentService = beanFactory.getBean("studentServiceProxy", StudentService.class);
        Student student = new Student();
        student.setName("张三");
        student.setAge(18);
        studentService.saveStudent(student);


    }
}
